<script>
	import Vue from 'vue';
	export default {
		mixins: [],
		data() {
			return {
				
			}
		},
		onLaunch(data) {
			this.checkVersion()
			uni.getLocation({
				type: 'gcj02',
				success: (res) => {
					uni.setStorage({
						key: 'location',
						data: {
							latitude: res.latitude,
							longitude: res.longitude
						}
					})
				}
			})
			//判断是否支持 获取本地位置
			// #ifdef H5
			if (navigator.geolocation) {
				var n = navigator.geolocation.getCurrentPosition(function(res) {
					console.log(res); // 需要的坐标地址就在res中
				});
			} else {
				console.log('该浏览器不支持定位');
			}
			// #endif
		},
		methods: {
			/**
			 * 检查小程序版本
			 */
			checkVersion:function(){
				// #ifdef MP
				const updateManager = uni.getUpdateManager();
				updateManager.onCheckForUpdate(function(res) {
					// 请求完新版本信息的回调
				});
				
				updateManager.onUpdateReady(function(res) {
					uni.showModal({
						title: '更新提示',
						content: '新版本已经准备好，是否重启应用？',
						success(res) {
							if (res.confirm) {
								// 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
								updateManager.applyUpdate();
							}
						}
					});
				});
				updateManager.onUpdateFailed(function(res) {
					// 新的版本下载失败
				});
				// #endif
			},
			onLoadSystemInfo: function() {
				uni.getSystemInfo({
					success: function(e) {
						// console.log("小程序")
						// console.log(e)
						// #ifndef MP
						Vue.prototype.StatusBar = e.statusBarHeight;
						if (e.platform == 'android') {
							Vue.prototype.CustomBar = e.statusBarHeight + 50;
							Vue.prototype.StickHeight = e.statusBarHeight * 2 + 50;
						} else {
							Vue.prototype.CustomBar = e.statusBarHeight + 45;
							Vue.prototype.StickHeight = e.statusBarHeight * 2 + 45;
						}
						// #endif

						// #ifdef MP-WEIXIN
						Vue.prototype.StatusBar = e.statusBarHeight;
						let custom = wx.getMenuButtonBoundingClientRect();
						Vue.prototype.Custom = custom;
						let navbar = custom.bottom + custom.top - e.statusBarHeight;
						Vue.prototype.CustomBar = navbar;
						//console.log('width:',e.windowWidth);
						Vue.prototype.Devwidth = e.windowWidth;
						Vue.prototype.DevHeight = e.screenHeight - navbar;
						Vue.prototype.StickHeight = navbar + e.statusBarHeight;
						// #endif

						// #ifdef MP-ALIPAY
						Vue.prototype.StatusBar = e.statusBarHeight;
						Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
						Vue.prototype.StickHeight = e.statusBarHeight * 2 + e.titleBarHeight;
						// #endif
						//#ifdef MP-TOUTIAO
						Vue.prototype.StatusBar = e.statusBarHeight;
						Vue.prototype.CustomBar = e.statusBarHeight + 45;
						Vue.prototype.StickHeight = e.statusBarHeight * 2 + 45;
						//#endif
						Vue.prototype.ScreenHeight = e.windowHeight;
						Vue.prototype.ScreenWidth = e.windowWidth;

					}
				});
			}
		},
		globalData: {
			isAuthorize: false
		}
	};
</script>
<style>
	/*每个页面公共css */
	@import url('/common/css/colorui/main.css');
	@import url('/common/css/colorui/icon.css');
	@import url('/common/css/colorui/animation.css');
	@import url('/common/css/colorui/uinorm.css');
</style>
<style lang="scss">
	/* #ifdef H5 */
	uni-page[data-page="otherpages/index/city/city"] {
		overflow: hidden !important;
	}

	/* #endif */
	::-webkit-scrollbar {
			width: 0;
			height: 0;
			background-color: transparent;
		} 
	/* #ifdef H5 */
			::-webkit-scrollbar {
				display: none;  
				width: 0 !important;  
				height: 0 !important;  
				-webkit-appearance: none;  
				background: transparent;  
			}
		/* #endif */
</style>
